import { Assert } from "@koalaui/harness"
import { AppControl } from "./loader"

export function entry(control: AppControl) {
    suite("Case1", () => {
        test("StateChange:Increment", () => {
            // onChange
            control
                .loadPage("Case1")
                .start()
                .emitTask(1, 42, 0, 0).nextFrame()
                .emitTask(1, 42, 0, 0).nextFrame()
                .emitTask(1, 42, 0, 0).nextFrame()
                .stop()
            let x = 3
            Assert.equal(x, 3, "StateChange test is failed!\n expected: " + 3 + "\ncurrent: " + x)
        })
    })
    suite("Case2", () => {
        test("StateChange:Decrement", () => {
            // onChange
            control
                .loadPage("Case2")
                .start()
                .emitTask(1, 42, 0, 0).nextFrame()
                .emitTask(1, 42, 0, 0).nextFrame()
                .emitTask(1, 42, 0, 0).nextFrame()
                .stop()
            let x = -3
            Assert.equal(x, -3, "StateChange test is failed!\n expected: " + (-3) + "\ncurrent: " + x)
        })
    })
}
